<template>
  <div>
    <Header></Header>
    <subnav></subnav>

    <!--主体-->
    <!-- container -->
    <div class="container">
      <div class="movies-channel">
        <div class="tags-panel">
          <ul class="tags-lines">
            <li class="tags-line">
              <div class="tags-title">类型 :</div>
              <ul class="tags">
                <li class="active">
                  <a href="">全部</a>
                </li>
              </ul>
            </li>
            <li class="tags-line tags-line-border">
              <div class="tags-title">区域 :</div>
              <ul class="tags">
                <li class="active">
                  <a href="">全部</a>
                </li>
              </ul>
            </li>
            <li class="tags-line tags-line-border">
              <div class="tags-title">年代 :</div>
              <ul class="tags">
                <li class="active">
                  <a href="">全部</a>
                </li>
              </ul>
            </li>
          </ul>
        </div>
        <div class="movies-panel">
          <div class="movies-sorter">
            <div class="cat-sorter">
              <ul>
                <li>
                  <span
                    class="sort-control-group"
                    data-act="sort-click"
                    data-val="{tagId: 1 }"
                    style="cursor: default"
                  >
                    <span class="sort-control sort-radio-checked"></span>
                    <span class="sort-control-label">按热门排序</span>
                  </span>
                </li>
                <li>
                  <span
                    class="sort-control-group"
                    data-act="sort-click"
                    data-val="{tagId: 2 }"
                    data-href="?sortId=2"
                    onclick="location.href=this.getAttribute('data-href')"
                  >
                    <span class="sort-control sort-radio"></span>
                    <span class="sort-control-label">按时间排序</span>
                  </span>
                </li>
                <li>
                  <span
                    class="sort-control-group"
                    data-act="sort-click"
                    data-val="{tagId: 3 }"
                    data-href="?sortId=3"
                    onclick="location.href=this.getAttribute('data-href')"
                  >
                    <span class="sort-control sort-radio"></span>
                    <span class="sort-control-label">按评价排序</span>
                  </span>
                </li>
              </ul>
            </div>
          </div>
        </div>
        <!-- 主体电影 -->
        <div class="movies-list" >
          <dl class="movie-list">
            <dd v-for="item in dataList" :key="item.filmId" @click="gotodetail(item.filmId)">
              <div class="movie-item film-channel">
                <a href="">
                  <div class="movie-poster">
                    <img src="../assets/film/3.png" alt="" />
                    <img :src="item.poster" alt="" />
                  </div>
                </a>
                <div class="channel-action channel-action-sale">
                  <a>购票</a>
                </div>
                <div class="movie-ver">
                  <i class="imax2d">{{ item.item.name }}</i>
                </div>
                <div class="movie-item-hover">
                  <a>
                    <img
                      class="movie-hover-img"
                      :src="item.poster"
                      alt="穿过寒冬拥抱你"
                    />
                    <div class="movie-hover-info">
                      <div class="movie-hover-title" title="穿过寒冬拥抱你">
                        <span class="name">{{ item.name }}</span>
                        <span class="score channel-detail-orange"
                          ><i class="integer">{{ item.grade }}</i
                          ><i class="fraction"></i
                        ></span>
                      </div>
                      <div class="movie-hover-title" title="穿过寒冬拥抱你">
                        <span class="hover-tag">类型:</span>
                        剧情／爱情
                      </div>
                      <div class="movie-hover-title" title="穿过寒冬拥抱你">
                        <span class="hover-tag">主演:</span>
                        {{ item.actors | actorfilter }}
                      </div>
                      <div
                        class="movie-hover-title movie-hover-brief"
                        title="穿过寒冬拥抱你"
                      >
                        <span class="hover-tag">上映时间:</span>
                        2021-12-31 18:00
                      </div>
                    </div>
                  </a>
                </div>
                <div
                  class="channel-detail movie-item-title"
                  title="穿过寒冬拥抱你"
                >
                  <a
                    href="/films/1444523"
                    target="_blank"
                    data-act="movies-click"
                    data-val="{movieId:1444523}"
                    >{{ item.name }}</a
                  >
                </div>
                <div class="channel-detail channel-detail-orange">
                  <i class="integer">{{ item.grade }}</i
                  ><i class="fraction"></i>
                </div>
              </div>
            </dd>
          </dl>
        </div>
      </div>
    </div>
    <!--分页器-->
    <el-pagination background layout="prev, pager, next" :total="dataList.total">
    </el-pagination>

    <low></low>
  </div>
</template>

<script>
import low from "../components/low";
import Header from "../components/Header";
import subnav from "../components/subnav";
import http from "../api/http";
export default {
  name: "film",
  data() {
    return {
      dataList: [],
      current: 1,
      total: 0
    };
  },
  components: {
    low,
    Header,
    subnav
  },
  mounted() {
    http({
      url: `/gateway?cityId=${this.$store.state.cityId}&pageNum=1&pageSize=10&type=1&k=3819095`,
      headers: {
        "X-Host": "mall.film-ticket.film.list"
      }
    }).then(res => {
      console.log(res);
      if (res.status == 0) {
        console.log(res.data);
        let { films } = res.data;
        this.dataList = films;
      }
    });
  },
  filters: {
    actorfilter(actors) {
      if (actors === undefined) return "暂无主演";
      return actors.map(item => item.name).join(" ");
    }
  },
  methods:{
    gotodetail(myid){
      this.$router.push('/detail/'+myid)
    }
  }
};
</script>

<style scoped>

.el-pagination {
    text-align: center;
    margin-top: 15px;
}


/* 主体 */
.container {
  width: 1200px;
  margin: 0 auto;
}
/* 标签 */
.movies-channel {
  width: 1120px;
  margin: auto;
}
.tags-panel {
  border: 1px solid #e5e5e5;
  padding: 0 20px;
  margin-top: 40px;
}
.tags-line {
  padding: 10px 0;
}
.tags-line-border {
  border-top: 1px dotted #e5e5e5;
}
.tags-title {
  height: 24px;
  line-height: 24px;
  float: left;
  color: #999;
  font-size: 14px;
}
.tags li.active {
  background: #f34d41;
  color: #fff;
}
.tags li {
  border-radius: 14px;
  padding: 3px 9px;
  display: inline-block;
  margin-left: 12px;
}
.tags li.active a {
  color: #fff;
}
.tags li a {
  color: #333;
  font-size: 14px;
}
/* 主体 */
.movies-panel {
  margin-top: 40px;
}
.movies-sorter {
  overflow: hidden;
}
.movies-sorter .cat-sorter {
  float: left;
  padding-left: 2px;
}
.movies-sorter li {
  display: inline-block;
  height: 16px;
  line-height: 18px;
  margin-right: 30px;
}
.sort-control-group {
  cursor: pointer;
  line-height: 16px;
}
.sort-radio-checked {
  background: url(../assets/film/1.png) no-repeat;
}
.sort-radio {
  background: url(../assets/film/2.png) no-repeat;
}
.sort-control {
  display: inline-block;
  vertical-align: top;
  width: 16px;
  height: 16px;
  margin-right: 2px;
}
.sort-control-label {
  font-size: 14px;
  vertical-align: top;
}

/* 主体 */
.movies-list {
  margin-top: 20px;
}
.movie-list dd {
  margin: 30px 0 0 30px;
  display: inline-block;
  vertical-align: top;
  position: relative;
}
.movie-item {
  position: relative;
  margin: -1px;
}
.movie-poster {
  background-color: #fcfcfc;
  width: 160px;
  height: 220px;
  overflow: hidden;
  position: relative;
}
.movie-poster .poster-default {
  top: 50%;
  left: 50%;
  width: 68px;
  height: 62px;
  margin-top: -31px;
  margin-left: -34px;
}
.movie-poster img {
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}
.channel-action-sale {
  background-color: #f34d41;
}
.channel-action {
  position: absolute;
  right: 5px;
  bottom: 80px;
  padding: 0 3px;
  height: 18px;
  line-height: 18px;
  border-radius: 1px;
}
.channel-action a {
  color: #fff;
  font-size: 12px;
  vertical-align: top;
}
.movie-ver {
  position: absolute;
  top: 4px;
  left: -2px;
  font-size: 15px;
  color: #fff;
  background-color: skyblue;
}
.movie-ver i.imax2d {
  width: 69px;
  height: 25px;
}
.movie-ver i {
  display: inline-block;
}
.movie-item:hover .movie-item-hover {
  display: block;
}
.movie-item-hover {
  display: none;
  position: absolute;
  width: 218px;
  height: 300px;
  z-index: 10;
  top: -40px;
  left: -29px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 16px #fff, 0 0 6px rgba(0, 0, 0, 20%);
}

img.movie-hover-img {
  width: 218px;
  height: 300px;
  vertical-align: middle;
  position: absolute;
  z-index: 10;
}
.movie-hover-info {
  padding: 16px;
  height: 150px;
  box-sizing: border-box;
  position: absolute;
  z-index: 11;
  top: 150px;
  background: #fff;
  width: 218px;
}
.movie-hover-title:first-child {
  margin-top: 6px;
  font-size: 20px;
  color: #333;
  line-height: 20px;
}
.movie-hover-title {
  font-size: 16px;
  line-height: 16px;
  color: #999;
  margin-top: 12px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.movie-item-hover .name {
  float: left;
  width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.movie-item-hover .score {
  float: right;
  margin-right: 5px;
}
.channel-detail-orange,
.channel-detail-prescore {
  color: #ffb400;
}
.channel-detail-orange .integer {
  font-size: 24px;
}
.channel-detail-orange .fraction {
  font-size: 22px;
}
.hover-tag {
  color: #333;
}
.movie-hover-title:last-child {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 20px;
  margin-top: 10px;
}
.channel-detail {
  width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  font-size: 16px;
  color: #333;
  margin-top: 10px;
}
.channel-detail a {
  color: #333;
}
.channel-detail-orange,
.channel-detail-prescore {
  color: #ffb400;
}
.channel-detail-orange .integer {
  font-size: 24px;
}
.channel-detail-orange .fraction {
  font-size: 22px;
}
</style>
